package com.lunatic.enumdemo;

import lombok.Data;

import java.util.Objects;

@Data
public class Pizza {
    private PizzaStatus status;

    public boolean isOrder() {
        return getStatus() == PizzaStatus.ORDERED;
    }

    // 使用 Objects。equals() 方法，预防空指针异常
    public boolean isReady() {
        return Objects.equals(getStatus(), PizzaStatus.READY);
    }

    public boolean isDelivered() {
        return getStatus() == PizzaStatus.DELIVERED;
    }

    public int getDeliveryTimeInDays() {
        switch (status) {
            case ORDERED:
                return 5;
            case READY:
                return 2;
            case DELIVERED:
                return 0;
        }
        return 0;
    }

    public enum PizzaStatus {
        ORDERED,
        READY,
        DELIVERED;
    }
}
